package com.xinqi.controller;

import com.xinqi.bean.Shop;
import com.xinqi.common.R;
import com.xinqi.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * @author xin麒
 * @date 2023/3/5 22:02
 */
@RestController
@RequestMapping("/shop")
public class ShopController {

    private final static int DEFAULT_PAGE_SIZE = 3;
    @Autowired
    private ShopService shopService;
    @GetMapping("/getShopByPage")
    public R queryShopByType(
            @RequestParam(value = "current", defaultValue = "1") Integer current) {
        Page<Shop> page = shopService.query()
                .page(new Page<>(current, DEFAULT_PAGE_SIZE));
        // 返回数据
        return R.success(page.getRecords());
    }
}
